package owl2vowl.common.erropage;

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/**
 * 异常页面
 * 
 * @author yan
 *
 */
@Configuration
public class ErrorPagesConfig {
	@Bean
	public EmbeddedServletContainerCustomizer containerCustomizer() {
		return new EmbeddedServletContainerCustomizer() {
			@Override
			public void customize(ConfigurableEmbeddedServletContainer container) {
				// 状态码 错误页面的存储路径
				ErrorPage errorPage400 = new ErrorPage(HttpStatus.BAD_REQUEST, "/erropage/error-400.html");
				ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/erropage/error-404.html");
				ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/erropage/error-500.html");
				container.addErrorPages(errorPage400, errorPage404, errorPage500);
			}
		};
	}
}
